#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<string.h>
int main()
{
	int status=0;
	int _pipe_id[2];
	if(pipe(_pipe_id)<0)
	{	
		perror("pipe");
		exit(1);
	}
	pid_t id=fork();
	if(id<0)
	{
		perror("fork");
	}
	else if(id==0)
	{
		close(_pipe_id[0]);
		char my_buf[]="hello world";
		int count=0;
		while(1){
			count++;
			ssize_t size=write(_pipe_id[1],my_buf,strlen(my_buf));
			if(size>0)
			{
			printf("child%d\n",count);		;
			}
			else{
				printf("child_count=%d,size=%d\n",count,size);
				sleep(3);
			}
		}
	}
	else
	{
			sleep(1);
		close(_pipe_id[1]);
		char my_buf[1024];
		int count=15;
		while(count--)
		{
				sleep(5);

          		memset(my_buf,'\0',sizeof(my_buf));
		 		ssize_t size= read(_pipe_id[0],my_buf,sizeof(my_buf));
				printf("%d,%s\n",size,my_buf);
		}
	return 0;
	}
	
	}
